package com.raptor.base.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.lang.reflect.Type;

public class SerializationUtil {

    public static String serialize(Object obj)
    {
        return JSON.toJSONString(obj);
    }

    public static <T> T deserialize(String result,Class<T> clazz)
    {
        return JSON.parseObject(result, clazz);
    }

    public static String getString(String result,String propertyName)
    {
        return JSON.parseObject(result).getString(propertyName);
    }

    public static <T> T parseObject(String result, Type type)
    {
        return (T)JSONObject.parseObject(result,type);
    }

}
